<template>
  <div class="category-list">
    <h1>分类列表</h1>
    <el-table :data="items">
      <el-table-column prop="_id" label="ID" width="240"></el-table-column>
      <el-table-column prop="name" label="分类名称"></el-table-column>
      <el-table-column fixed="right" label="操作" width="180">
        <template slot-scope="scope">
          <el-button
            type="text"
            size="small"
            @click="$router.push(`/categoryedit/${scope.row._id}`)"
          >编辑</el-button>
        </template>
      </el-table-column>
    </el-table>
  </div>
</template>

<script>
export default {
  components: {},
  data() {
    return {
      items: []
    };
  },
  computed: {},
  methods: {
    async fetch() {
      const res = await this.$http.get("/admin/api/categories");
      this.items = res.data;
    }
  },
  created() {
    this.fetch();
  }
};
</script>

<style scoped>
</style>